/*     */ package com.wgcloud.controller;
/*     */

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.wgcloud.entity.*;
import com.wgcloud.service.*;
import com.wgcloud.util.DateUtil;
import com.wgcloud.util.FormatUtil;
import com.wgcloud.util.ThreadPoolUtil;
import com.wgcloud.util.TokenUtils;
import com.wgcloud.util.msg.WarnMailUtil;
import com.wgcloud.util.staticvar.BatchData;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/agentGo"})
/*     */ public class AgentGoController {
/*  40 */   private static final Logger logger = LoggerFactory.getLogger(com.wgcloud.controller.AgentGoController.class);
/*     */ 
/*     */   
/*     */   @Resource
/*     */   private LogInfoService logInfoService;
/*     */   
/*     */   @Resource
/*     */   private SystemInfoService systemInfoService;
/*     */   
/*     */   @Autowired
/*     */   DockerInfoService dockerInfoService;
/*     */   
/*     */   @Autowired
/*     */   AppInfoService appInfoService;
/*     */   
/*     */   @Autowired
/*     */ PortInfoService portInfoService;
/*     */   
/*     */   @Autowired
/*     */   private TokenUtils tokenUtils;
/*     */ 
/*     */   
/*     */   @ResponseBody
/*     */   @RequestMapping({"/minTask"})
/*     */   public JSONObject minTask(@RequestBody String paramBean) {
/*  65 */     JSONObject agentJsonObject = (JSONObject)JSONUtil.parse(paramBean);
/*  66 */     logger.debug("agent上报数据-------------" + agentJsonObject.toString());
/*  67 */     JSONObject resultJson = new JSONObject();
/*  68 */     if (!this.tokenUtils.checkAgentToken(agentJsonObject)) {
/*  69 */       logger.error("token is error");
/*  70 */       resultJson.set("result", "token is error");
/*  71 */       return resultJson;
/*     */     } 
/*     */     
/*  74 */     String bindIp = agentJsonObject.getStr("bindIp");
/*  75 */     if (isExists(bindIp)) {
/*  76 */       logger.error("agent multiple times at the same time：" + bindIp);
/*  77 */       resultJson.set("result", "agent multiple times at the same time：" + bindIp);
/*  78 */       return resultJson;
/*     */     } 
/*     */     
/*  81 */     String hostName = agentJsonObject.getStr("hostName");
/*     */     
/*  83 */     String recvBytes = agentJsonObject.getStr("recvBytes");
/*     */     
/*  85 */     String sentBytes = agentJsonObject.getStr("sentBytes");
/*     */     
/*  87 */     String agentVer = agentJsonObject.getStr("agentVer");
/*     */     
/*  89 */     String cpuCoresNum = agentJsonObject.getStr("cpuCoresNum");
/*     */     
/*  91 */     JSONObject hostInfoJson = agentJsonObject.getJSONObject("hostInfo");
/*     */     
/*  93 */     JSONObject dockersJson = agentJsonObject.getJSONObject("dockers");
/*     */     
/*  95 */     JSONObject portInfosJson = agentJsonObject.getJSONObject("portInfos");
/*     */     
/*  97 */     JSONObject loadJson = agentJsonObject.getJSONObject("load");
/*     */     
/*  99 */     JSONArray temperaturesJsonArray = agentJsonObject.getJSONArray("temperatures");
/*     */     
/* 101 */     String submitSeconds = agentJsonObject.getStr("submitSeconds");
/*     */ 
/*     */     
/* 104 */     JSONArray cpuInfoJson = null;
/*     */     
/*     */     try {
/* 107 */       cpuInfoJson = agentJsonObject.getJSONArray("cpuInfo");
/* 108 */       if (cpuInfoJson.size() < 1) {
/* 109 */         JSONObject cpuInfoJsonTmp = new JSONObject();
/* 110 */         cpuInfoJsonTmp.set("cores", Integer.valueOf(0));
/* 111 */         cpuInfoJsonTmp.set("modelName", "?");
/* 112 */         cpuInfoJson = new JSONArray();
/* 113 */         cpuInfoJson.add(cpuInfoJsonTmp);
/*     */       } 
/* 115 */     } catch (Exception e) {
/* 116 */       logger.error("cpuInfoJson is error : ", e);
/* 117 */       JSONObject cpuInfoJsonTmp = new JSONObject();
/* 118 */       cpuInfoJsonTmp.set("cores", Integer.valueOf(0));
/* 119 */       cpuInfoJsonTmp.set("modelName", "?");
/* 120 */       cpuInfoJson = new JSONArray();
/* 121 */       cpuInfoJson.add(cpuInfoJsonTmp);
/*     */     } 
/*     */ 
/*     */ 
/*     */     
/* 126 */     Double cpuPercentJson = agentJsonObject.getDouble("cpuPercent");
/*     */     
/* 128 */     JSONObject virtualMemoryJson = agentJsonObject.getJSONObject("virtualMemory");
/*     */ 
/*     */     
/* 131 */     JSONObject netIOCountersJson = agentJsonObject.getJSONObject("netIOCounters");
/*     */     
/* 133 */     JSONObject processListJson = agentJsonObject.getJSONObject("processList");
/* 134 */     Double cpuPercentVal = null;
/* 135 */     Double memTotalVal = null;
/* 136 */     Double memPercentVal = null;
/* 137 */     Double swapMemPercentVal = null;
/* 138 */     Date nowtime = DateUtil.getNowTime();
/*     */ 
/*     */     
/* 141 */     if (StringUtils.isEmpty(bindIp)) {
/* 142 */       bindIp = hostName;
/* 143 */       logger.error("bindIp is null");
/* 144 */       if (StringUtils.isEmpty(bindIp)) {
/* 145 */         resultJson.set("result", "error：bindIp is null");
/* 146 */         return resultJson;
/*     */       } 
/*     */     } 
/*     */ 
/*     */ 
/*     */     
/* 152 */     try { if (cpuPercentJson != null) {
/* 153 */         cpuPercentVal = Double.valueOf(FormatUtil.formatDouble(cpuPercentJson, 2));
/* 154 */         addCpuState(cpuPercentJson, nowtime, bindIp);
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 159 */       if (virtualMemoryJson != null) {
/* 160 */         if (virtualMemoryJson.getLong("total") != null) {
/* 161 */           memTotalVal = Double.valueOf(FormatUtil.formatDouble(Double.valueOf(virtualMemoryJson.getLong("total").longValue() / 1024.0D / 1024.0D / 1024.0D), 2));
/*     */         } else {
/* 163 */           memTotalVal = Double.valueOf(0.0D);
/*     */         } 
/* 165 */         if (virtualMemoryJson.getDouble("usedPercent") != null) {
/* 166 */           memPercentVal = Double.valueOf(FormatUtil.formatDouble(virtualMemoryJson.getDouble("usedPercent"), 2));
/*     */         } else {
/* 168 */           memPercentVal = Double.valueOf(0.0D);
/*     */         } 
/* 170 */         addMemState(memPercentVal, nowtime, bindIp);
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 175 */       SysLoadState sysLoadState = null;
/* 176 */       if (loadJson != null) {
/* 177 */         sysLoadState = addLoadState(loadJson, nowtime, bindIp);
/*     */       }
/*     */       
/* 180 */       NetIoState netIoState = null;
/* 181 */       if (netIOCountersJson != null) {
/* 182 */         netIoState = addNetIoState(netIOCountersJson, nowtime, bindIp);
/*     */       }
/*     */       
/* 185 */       if (processListJson != null) {
/* 186 */         addAppState(processListJson, nowtime, bindIp);
/*     */       }
/*     */       
/* 189 */       if (dockersJson != null) {
/* 190 */         addDockerState(dockersJson, nowtime, bindIp);
/*     */       }
/*     */       
/* 193 */       if (hostInfoJson != null && cpuInfoJson != null) {
/* 194 */         addSystemInfo(hostInfoJson, cpuInfoJson.getJSONObject(Integer.valueOf(0)), cpuPercentVal, memPercentVal, memTotalVal, nowtime, bindIp, submitSeconds, agentVer, recvBytes, sentBytes, netIoState, cpuCoresNum, hostName, sysLoadState);
/*     */       }
/*     */ 
/*     */       
/* 198 */       if (portInfosJson != null) {
/* 199 */         addPortInfos(portInfosJson, nowtime, bindIp);
/*     */       }
/*     */       
/* 202 */       if (temperaturesJsonArray != null) {
/* 203 */         addCpuTemperatures(temperaturesJsonArray, nowtime, bindIp);
/*     */       }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */       
/* 210 */       return resultJson; } catch (Exception e) { logger.error("解析上报数据错误", e); return resultJson; } finally { Exception exception = null; }
/*     */   
/*     */   }
/*     */   
/*     */   private void addMemState(Double memPercentJson, Date nowtime, String bindIp) {
/*     */     try {
/* 216 */       MemState bean = new MemState();
/* 217 */       bean.setUsePer(memPercentJson);
/* 218 */       bean.setCreateTime(nowtime);
/* 219 */       bean.setHostname(bindIp);
/* 220 */       BatchData.MEM_STATE_LIST.add(bean);
/* 221 */       Runnable runnable = () -> WarnMailUtil.sendWarnInfo(bean);
/*     */ 
/*     */       
/* 224 */       ThreadPoolUtil.executor.execute(runnable);
/* 225 */     } catch (Exception e) {
/* 226 */       logger.error("解析内存使用率上报数据错误", e);
/*     */     } 
/*     */   }
/*     */   
/*     */   private void addCpuState(Double cpuPercentJson, Date nowtime, String bindIp) {
/*     */     try {
/* 232 */       CpuState bean = new CpuState();
/* 233 */       bean.setHostname(bindIp);
/* 234 */       Double cpuPercentVal = Double.valueOf(FormatUtil.formatDouble(cpuPercentJson, 2));
/* 235 */       bean.setSys(cpuPercentVal);
/* 236 */       bean.setCreateTime(nowtime);
/* 237 */       BatchData.CPU_STATE_LIST.add(bean);
/* 238 */       Runnable runnable = () -> WarnMailUtil.sendCpuWarnInfo(bean);
/*     */ 
/*     */       
/* 241 */       ThreadPoolUtil.executor.execute(runnable);
/* 242 */     } catch (Exception e) {
/* 243 */       logger.error("解析cpu使用率上报数据错误", e);
/*     */     } 
/*     */   }
/*     */   
/*     */   private SysLoadState addLoadState(JSONObject loadJson, Date nowtime, String bindIp) {
/* 248 */     SysLoadState bean = new SysLoadState();
/*     */     try {
/* 250 */       bean.setHostname(bindIp);
/* 251 */       bean.setOneLoad(loadJson.getDouble("load1"));
/* 252 */       bean.setFiveLoad(loadJson.getDouble("load5"));
/* 253 */       bean.setFifteenLoad(loadJson.getDouble("load15"));
/* 254 */       bean.setCreateTime(nowtime);
/* 255 */       BatchData.SYSLOAD_STATE_LIST.add(bean);
/* 256 */     } catch (Exception e) {
/* 257 */       logger.error("解析系统负载上报数据错误", e);
/*     */     } 
/* 259 */     return bean;
/*     */   }
/*     */   
/*     */   private NetIoState addNetIoState(JSONObject netIOCountersJson, Date nowtime, String bindIp) {
/* 263 */     NetIoState bean = new NetIoState();
/*     */     try {
/* 265 */       if (netIOCountersJson.getDouble("res_recv_bytes") != null) {
/* 266 */         bean.setRxbyt(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_recv_bytes"), 2) + "");
/*     */       } else {
/* 268 */         bean.setRxbyt("0");
/*     */       } 
/* 270 */       if (netIOCountersJson.getDouble("res_sent_bytes") != null) {
/* 271 */         bean.setTxbyt(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_sent_bytes"), 2) + "");
/*     */       } else {
/* 273 */         bean.setTxbyt("0");
/*     */       } 
/* 275 */       if (netIOCountersJson.getDouble("res_sent_packets") != null) {
/* 276 */         bean.setTxpck(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_sent_packets"), 2) + "");
/*     */       } else {
/* 278 */         bean.setTxpck("0");
/*     */       } 
/* 280 */       if (netIOCountersJson.getDouble("res_recv_packets") != null) {
/* 281 */         bean.setRxpck(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_recv_packets"), 2) + "");
/*     */       } else {
/* 283 */         bean.setRxpck("0");
/*     */       } 
/* 285 */       if (netIOCountersJson.getDouble("res_dropin_packets") != null) {
/* 286 */         bean.setDropin(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_dropin_packets"), 2) + "");
/*     */       } else {
/* 288 */         bean.setDropin("0");
/*     */       } 
/* 290 */       if (netIOCountersJson.getDouble("res_dropout_packets") != null) {
/* 291 */         bean.setDropout(FormatUtil.formatDouble(netIOCountersJson.getDouble("res_dropout_packets"), 2) + "");
/*     */       } else {
/* 293 */         bean.setDropout("0");
/*     */       } 
/* 295 */       bean.setCreateTime(nowtime);
/* 296 */       bean.setHostname(bindIp);
/* 297 */       BatchData.NETIO_STATE_LIST.add(bean);
/* 298 */       Runnable runnable = () -> {
/*     */           try {
/*     */             if (bean != null) {
/*     */               WarnMailUtil.sendDownSpeedWarnInfo(bean);
/*     */               WarnMailUtil.sendUpSpeedWarnInfo(bean);
/*     */             } 
/* 304 */           } catch (Exception e) {
/*     */             e.printStackTrace();
/*     */           } 
/*     */         };
/* 308 */       ThreadPoolUtil.executor.execute(runnable);
/* 309 */     } catch (Exception e) {
/* 310 */       logger.error("解析网络流量上报数据错误", e);
/*     */     } 
/* 312 */     return bean;
/*     */   }
/*     */   
/*     */   private void addAppState(JSONObject processListJson, Date nowtime, String bindIp) {
/*     */     try {
/* 317 */       List<String> keys = new ArrayList<>(processListJson.keySet());
/* 318 */       for (String proId : keys) {
/* 319 */         String[] vals = processListJson.getStr(proId).split(",");
/* 320 */         AppInfo appInfo = new AppInfo();
/* 321 */         appInfo.setHostname(bindIp);
/* 322 */         appInfo.setId(proId);
/* 323 */         appInfo.setCreateTime(nowtime);
/* 324 */         appInfo.setState("1");
/* 325 */         appInfo.setMemPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(vals[1]), 2)));
/* 326 */         appInfo.setCpuPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(vals[0]), 2)));
/* 327 */         appInfo.setReadBytes(FormatUtil.formatDouble(Double.valueOf(vals[2]), 2) + "");
/* 328 */         appInfo.setWritesBytes(FormatUtil.formatDouble(Double.valueOf(vals[3]), 2) + "");
/*     */ 
/*     */         
/* 331 */         if (appInfo.getCpuPer().doubleValue() < 0.0D) {
/* 332 */           appInfo.setState("2");
/* 333 */           BatchData.APP_INFO_LIST.add(appInfo);
/* 334 */           Runnable runnable = () -> {
/*     */               try {
/*     */                 AppInfo appInfoW = this.appInfoService.selectById(proId);
/*     */                 if (appInfoW != null) {
/*     */                   WarnMailUtil.sendAppDown(appInfoW, true);
/*     */                 }
/* 340 */               } catch (Exception e) {
/*     */                 e.printStackTrace();
/*     */               } 
/*     */             };
/*     */           
/* 345 */           ThreadPoolUtil.executor.execute(runnable);
/*     */           
/*     */           continue;
/*     */         } 
/*     */         
/* 350 */         BatchData.APP_INFO_LIST.add(appInfo);
/* 351 */         AppState appState = new AppState();
/* 352 */         appState.setAppInfoId(proId);
/* 353 */         appState.setCreateTime(nowtime);
/* 354 */         appState.setCpuPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(vals[0]), 2)));
/* 355 */         appState.setMemPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(vals[1]), 2)));
/* 356 */         BatchData.APP_STATE_LIST.add(appState);
/*     */       } 
/* 358 */     } catch (Exception e) {
/* 359 */       logger.error("解析进程上报数据错误", e);
/*     */     } 
/*     */   }
/*     */   
/*     */   private void addDockerState(JSONObject dockersJson, Date nowtime, String bindIp) {
/*     */     try {
/* 365 */       List<String> keys = new ArrayList<>(dockersJson.keySet());
/* 366 */       for (String dockerId : keys) {
/* 367 */         String[] vals = dockersJson.getStr(dockerId).split(",");
/* 368 */         DockerInfo dockerInfo = new DockerInfo();
/* 369 */         dockerInfo.setId(dockerId);
/* 370 */         dockerInfo.setCreateTime(nowtime);
/* 371 */         dockerInfo.setState("1");
/* 372 */         dockerInfo.setHostname(bindIp);
/* 373 */         dockerInfo.setMemPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(vals[2]), 2)));
/* 374 */         dockerInfo.setSystemTime(FormatUtil.formatDouble(Double.valueOf(vals[0]), 2) + "");
/* 375 */         dockerInfo.setUserTime(FormatUtil.formatDouble(Double.valueOf(vals[1]), 2) + "");
/*     */ 
/*     */         
/* 378 */         if (Double.valueOf(vals[0]).doubleValue() < 0.0D) {
/* 379 */           dockerInfo.setState("2");
/* 380 */           BatchData.DOCKER_INFO_LIST.add(dockerInfo);
/* 381 */           Runnable runnable = () -> {
/*     */               try {
/*     */                 DockerInfo dockerInfoW = this.dockerInfoService.selectById(dockerId);
/*     */                 if (dockerInfoW != null) {
/*     */                   WarnMailUtil.sendDockerDown(dockerInfoW, true);
/*     */                 }
/* 387 */               } catch (Exception e) {
/*     */                 e.printStackTrace();
/*     */               } 
/*     */             };
/*     */           
/* 392 */           ThreadPoolUtil.executor.execute(runnable);
/*     */ 
/*     */           
/*     */           continue;
/*     */         } 
/*     */         
/* 398 */         BatchData.DOCKER_INFO_LIST.add(dockerInfo);
/* 399 */         DockerState dockerState = new DockerState();
/* 400 */         dockerState.setDockerInfoId(dockerId);
/* 401 */         dockerState.setCreateTime(nowtime);
/* 402 */         dockerState.setMemPer(dockerInfo.getMemPer());
/* 403 */         BatchData.DOCKER_STATE_LIST.add(dockerState);
/*     */       } 
/* 405 */     } catch (Exception e) {
/* 406 */       logger.error("解析docker上报数据错误", e);
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void addSystemInfo(JSONObject hostInfoJson, JSONObject cpuInfoJson, Double cpuPercentVal, Double memPercentVal, Double memTotalVal, Date nowtime, String bindIp, String submitSeconds, String agentVer, String recvBytes, String sentBytes, NetIoState netIoState, String cpuCoresNum, String hostNameExt, SysLoadState sysLoadState) throws Exception {
/* 426 */     SystemInfo bean = new SystemInfo();
/* 427 */     bean.setSubmitSeconds(submitSeconds);
/* 428 */     bean.setAgentVer(agentVer);
/* 429 */     bean.setState("1");
/* 430 */     bean.setHostname(bindIp);
/* 431 */     bean.setHostnameExt(hostNameExt);
/* 432 */     bean.setCreateTime(nowtime);
/* 433 */     bean.setBootTime(hostInfoJson.getLong("bootTime"));
/* 434 */     bean.setUptime(hostInfoJson.getLong("uptime"));
/* 435 */     bean.setCpuPer(cpuPercentVal);
/* 436 */     bean.setMemPer(memPercentVal);
/* 437 */     bean.setProcs(hostInfoJson.getStr("procs"));
/* 438 */     bean.setCpuCoreNum(cpuCoresNum);
/* 439 */     bean.setCpuXh(cpuInfoJson.getStr("modelName"));
/* 440 */     bean.setPlatForm(hostInfoJson.getStr("platform"));
/* 441 */     bean.setPlatformVersion(hostInfoJson.getStr("platformVersion"));
/* 442 */     bean.setTotalMem(memTotalVal + "G");
/* 443 */     if (null == netIoState) {
/* 444 */       netIoState = new NetIoState();
/*     */     }
/* 446 */     bean.setRxbyt(netIoState.getRxbyt());
/* 447 */     bean.setTxbyt(netIoState.getTxbyt());
/* 448 */     if (null == sysLoadState) {
/* 449 */       sysLoadState = new SysLoadState();
/*     */     }
/* 451 */     bean.setFiveLoad(sysLoadState.getFiveLoad());
/* 452 */     bean.setFifteenLoad(sysLoadState.getFifteenLoad());
/* 453 */     if (!StringUtils.isEmpty(recvBytes)) {
/* 454 */       bean.setBytesRecv(FormatUtil.formatDouble(Double.valueOf(recvBytes), 2) + "");
/*     */     } else {
/* 456 */       bean.setBytesRecv("0");
/*     */     } 
/* 458 */     if (!StringUtils.isEmpty(sentBytes)) {
/* 459 */       bean.setBytesSent(FormatUtil.formatDouble(Double.valueOf(sentBytes), 2) + "");
/*     */     } else {
/* 461 */       bean.setBytesSent("0");
/*     */     } 
/* 463 */     BatchData.SYSTEM_INFO_LIST.add(bean);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void addCpuTemperatures(JSONArray temperaturesJsonArray, Date nowtime, String bindIp) {
/*     */     try {
/* 476 */       logger.debug("addCpuTemperatures--------------" + temperaturesJsonArray.toString());
/* 477 */       Set<String> coreSet = new HashSet<>();
/*     */       
/* 479 */       for (Object temperaturesObj : temperaturesJsonArray) {
/* 480 */         JSONObject temperaturesJson = JSONUtil.parseObj(temperaturesObj);
/* 481 */         String sensor = temperaturesJson.getStr("sensorKey");
/*     */ 
/*     */         
/* 484 */         if (sensor.indexOf("_core") > 0) {
/* 485 */           String[] sensors = sensor.split("_");
/* 486 */           if (sensors.length < 3) {
/*     */             continue;
/*     */           }
/* 489 */           coreSet.add(sensors[1]);
/*     */ 
/*     */           
/*     */           continue;
/*     */         } 
/*     */         
/* 495 */         if (sensor.indexOf("ThermalZone") > 0) {
/* 496 */           coreSet.add(sensor);
/*     */         }
/*     */       } 
/*     */ 
/*     */ 
/*     */ 
/*     */       
/* 503 */       for (String coreIndex : coreSet) {
/* 504 */         CpuTemperatures cpuTemperatures = new CpuTemperatures();
/* 505 */         cpuTemperatures.setHostname(bindIp);
/* 506 */         cpuTemperatures.setCreateTime(nowtime);
/* 507 */         cpuTemperatures.setCore_index(coreIndex);
/* 508 */         for (Object temperaturesObj : temperaturesJsonArray) {
/* 509 */           JSONObject temperaturesJson = JSONUtil.parseObj(temperaturesObj);
/* 510 */           String sensor = temperaturesJson.getStr("sensorKey");
/* 511 */           String sensorTemperature = temperaturesJson.getStr("sensorTemperature");
/*     */ 
/*     */           
/* 514 */           if (sensor.indexOf(coreIndex) > -1 && sensor.indexOf("ThermalZone") < 0) {
/* 515 */             if (sensor.endsWith("_crit")) {
/* 516 */               cpuTemperatures.setCrit(sensorTemperature);
/*     */             }
/* 518 */             if (sensor.endsWith("_input")) {
/* 519 */               cpuTemperatures.setInput(sensorTemperature);
/*     */             }
/* 521 */             if (sensor.endsWith("_max")) {
/* 522 */               cpuTemperatures.setMax(sensorTemperature);
/*     */             }
/*     */ 
/*     */             
/*     */             continue;
/*     */           } 
/*     */           
/* 529 */           if (sensor.indexOf(coreIndex) > -1 && sensor.indexOf("ThermalZone") > 0) {
/* 530 */             cpuTemperatures.setCrit("");
/* 531 */             cpuTemperatures.setInput(sensorTemperature);
/* 532 */             cpuTemperatures.setMax("");
/*     */           } 
/*     */         } 
/*     */         
/* 536 */         BatchData.CPU_TEMPERATURES_LIST.add(cpuTemperatures);
/* 537 */         Runnable runnable = () -> WarnMailUtil.sendCpuTemperatures(cpuTemperatures);
/*     */ 
/*     */         
/* 540 */         ThreadPoolUtil.executor.execute(runnable);
/*     */       } 
/* 542 */     } catch (Exception e) {
/* 543 */       logger.error("解析cpu温度上报数据错误", e);
/*     */     } 
/*     */   }
/*     */   
/*     */   private void addPortInfos(JSONObject portInfoJson, Date nowtime, String bindIp) {
/*     */     try {
/* 549 */       List<String> keys = new ArrayList<>(portInfoJson.keySet());
/* 550 */       for (String portId : keys) {
/* 551 */         String state = portInfoJson.getStr(portId);
/* 552 */         PortInfo portInfo = new PortInfo();
/* 553 */         portInfo.setId(portId);
/* 554 */         portInfo.setCreateTime(nowtime);
/* 555 */         portInfo.setState(state);
/* 556 */         portInfo.setHostname(bindIp);
/*     */ 
/*     */         
/* 559 */         if (!"1".equals(state)) {
/* 560 */           portInfo.setState("2");
/* 561 */           BatchData.PORT_INFO_LIST.add(portInfo);
/* 562 */           Runnable runnable = () -> {
/*     */               try {
/*     */                 PortInfo portInfoW = this.portInfoService.selectById(portId);
/*     */                 if (portInfoW != null) {
/*     */                   WarnMailUtil.sendPortDown(portInfoW, true);
/*     */                 }
/* 568 */               } catch (Exception e) {
/*     */                 e.printStackTrace();
/*     */               } 
/*     */             };
/*     */           
/* 573 */           ThreadPoolUtil.executor.execute(runnable);
/*     */           
/*     */           continue;
/*     */         } 
/*     */         
/* 578 */         BatchData.PORT_INFO_LIST.add(portInfo);
/*     */       } 
/* 580 */     } catch (Exception e) {
/* 581 */       logger.error("解析端口上报数据错误", e);
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private boolean isExists(String bindIp) {
/* 592 */     if (StringUtils.isEmpty(bindIp)) {
/* 593 */       return true;
/*     */     }
/* 595 */     for (SystemInfo systemInfo : BatchData.SYSTEM_INFO_LIST) {
/* 596 */       if (systemInfo.getHostname().equals(bindIp)) {
/* 597 */         return true;
/*     */       }
/*     */     } 
/* 600 */     return false;
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/controller/AgentGoController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */